home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 May: Tool Chest / Dev.CD May 97 TC.toast / Sample Code / Snippets / Files / Is PC Exchange Installed / IsPCExchangeInstalled.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-09  |  2.1 KB  |  92 lines  |  [TEXT/CWIE]

  1. /******************************************************************************************
  2.     IsPCExchangeInstalled.c
  3.  
  4.     Written by Jim Luther with some modifications by Virginia McCulloh
  5.     Apple Developer Technical Support
  6.     August, 1996, Cupertino, CA
  7.     Copyright 1996, Apple Computer, Inc.
  8.     
  9.     This snippet demonstrates the check for the existence of PC Exchange.
  10.     The FSMGlueLib.o file is available on the MacOS SDK CD in the File
  11.     System Manager Libraries folder.
  12.  
  13.     This runs under Metrowerks CodeWarrior 8 with the Universal 
  14.     Interfaces 2.1 from ETO #18.
  15.  
  16. /*****************************************************************************/
  17.  
  18. #include <Gestalt.h>
  19. #include <FSM.h>
  20.  
  21. static    Boolean    HasFSM(void);
  22. Boolean    IsMacPCExchangeInstalled(void);
  23.  
  24.  
  25. /*
  26. **    HasFSM determines if the File System Manager is available.
  27. */
  28. static    Boolean    HasFSM(void)
  29. {
  30.     long    response;
  31.     Boolean    result;
  32.     
  33.     result = false;
  34.     
  35.     /* Make sure the File System Manager is installed */
  36.     if ( Gestalt(gestaltFSAttr, &response) == noErr )
  37.     {
  38.         if ( (response & (1L << gestaltHasFileSystemManager)) != 0 )
  39.         {
  40.             result = true;
  41.         }
  42.     }
  43.     
  44.     return ( result );
  45. }
  46.  
  47. /*****************************************************************************/
  48.  
  49. /*
  50. **    IsMacPCExchangeInstalled determines if Macintosh PC Exchange has installed
  51. **    the MS-DOS foreign file system.
  52. */
  53. Boolean    IsMacPCExchangeInstalled(void)
  54. {
  55.     enum
  56.     {
  57.         kMacPCExchangeFSID = 0x4953    /* file system ID of Macintosh PC Exchange's
  58.                                         MS-DOS file system */
  59.     };
  60.     Boolean    result;
  61.     short    bufSize;    /* The size of the FSDRec */
  62.     FSDRec    theFSDRec;    /* The FSDRec */
  63.     
  64.     result = false;     /* default to no Macintosh PC Exchange */
  65.     
  66.     /* Make sure the File System Manager is available */
  67.     if ( HasFSM() )
  68.     {
  69.         bufSize = sizeof(FSDRec);
  70.         if ( GetFSInfo(fsmGetFSInfoByFSID, kMacPCExchangeFSID, &bufSize, &theFSDRec) == noErr )
  71.         {
  72.             result = true;
  73.         }
  74.     }
  75.     
  76.     return ( result );
  77. }
  78.  
  79. /*****************************************************************************/
  80.  
  81. /* Test code */
  82. void    main(void)
  83. {
  84.     if ( IsMacPCExchangeInstalled() )
  85.     {
  86.         DebugStr("\pMacintosh PC Exchange is installed");
  87.     }
  88.     else
  89.     {
  90.         DebugStr("\pMacintosh PC Exchange is NOT installed");
  91.     }
  92. }